import React, { Component } from 'react';
import { List, ConfigProvider, Empty } from 'antd';
import { Link } from 'react-router-dom';
import Wheaders from '../../components/Headers';
import Http from '../../util/http';
import './index.less';

class Login extends Component {
    constructor(props){
        super(props);
        this.state = {
            read_History: []
        }
    }

    render() {
        const { read_History } = this.state;

        return (
            <div className='reading-history'>
                <Wheaders left={'返回'} middle={'阅读历史'} right={'我的'} />
                <div className={'main'}>
                <ConfigProvider
                        renderEmpty={() => (
                            <Empty description={<span> 暂无阅读记录~</span>} />
                        )}>
                    <List
                        size='small'
                        dataSource={read_History}
                        renderItem={item => (
                            <List.Item className={'list-item'}>
                                <Link to={{pathname:'/reading', state: {
                                    novelInfo: item,
                                    orderNum: item.orderNum,
                                }}}>
                                    <h2>{item.novelName}</h2>
                                    <p>{item.tagName}</p>
                                    <p>
                                        <span className={'progress'}>{item.isDont === 'Y' ? '已完结' : '连载中'}</span>
                                        {item.chapterName}
                                    </p>
                                </Link>
                            </List.Item>
                        )}
                    />
                </ConfigProvider>
                    
                </div>
            </div>
        );
    }

    componentDidMount() {
        this.gerReadLog();
    }

    gerReadLog () {
        Http.get('/Novel/getReadLog').then( respone => {
            this.setState({ read_History: respone.resultData });
        });
    }
}
export default Login;


